package com.fishleap.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fishleap.entity.Article;
import com.fishleap.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author zlg
 * @create 2020-05-24 8:45
 */
@Controller
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping(value = "/list/{pageNum}/{pageSize}",method = RequestMethod.GET)
    public ModelAndView findAll(@PathVariable("pageNum") Integer pageNum,@PathVariable("pageSize") Integer pageSize) {
        ModelAndView modelAndView = new ModelAndView();
        Page<Article> articlePage = new Page<>(pageNum, pageSize);
        articleService.selectPageArticle(articlePage);
        modelAndView.addObject("articlePage",articlePage);
        modelAndView.setViewName("index");
        return modelAndView;
    }

}
